// API响应基础接口
export interface ApiResponse<T = any> {
    code: number;
    msg: string;
    data: T;
}

// 土地信息列表响应
export interface LandInfoData {
    total: string;
    records: LandInfoItem[];
}

export interface data {
    code: number;
    data: LandInfoData;
    msg: string;
}

// 土地信息项目接口
export interface LandInfoItem {
    id: any;
    roleId: any;
    landName: string;
    landsize: any;
    landQuality: string;
    climate: string;
    previousCro: string;
    isActive: any; // 0:闲置, 1:启用, 2:弃用
    landImage: string;
    landAddress: string;
    isPlanting: any;
    createTime: string;
    longitude: number;
    latitude: number;
    provinceCode: string;
    cityCode: string;
    areaCode: string;
    updateTime?: string;
}

// 新增土地表单接口 - 确保类型正确
export interface AddLandForm {
    id: any;
    landName: string;
    landsize: any;
    landQuality: string;
    climate: string;
    previousCro: string;
    isActive: any;
    landImage?: string;
    landAddress: string;
    isPlanting?: any;
    longitude: number;
    latitude: number;
    provinceCode: string;
    cityCode: string;
    areaCode: string;
}

// 编辑土地表单接口 - 包含ID
export interface EditLandForm extends AddLandForm {
    roleId: number;
}

// 表单验证接口 - 用于前端表单绑定
export interface LandFormData {
    id: any;
    roleId?: any;
    landName: string;
    landsize: any; // 允许字符串输入，稍后转换
    landQuality: string;
    climate: string;
    previousCro: string;
    isActive: any; // 允许字符串输入，稍后转换
    landImage: string;
    landAddress: string;
    isPlanting: any;
    createTime?: string;
    longitude: any; // 允许字符串输入，稍后转换
    latitude: any; // 允许字符串输入，稍后转换
    provinceCode: string;
    cityCode: string;
    areaCode: string;
    updateTime?: string;
}

// 土地状态更新响应
export interface UpdateLandStatusRes {
    code: string;
    msg: string;
    data: string;
}

// 省市区接口
export interface position {
    code: number;
    msg: string;
    data: positionItem[];
}

export interface positionItem {
    areaId: number;
    areaName: string;
    parentId: number;
    level: number;
    areas: string;
}

// 删除土地响应
export interface deleteAddress {
    code: number;
    msg: string;
    data: string;
}

// 回显土地信息响应
export interface findLandInfo {
    code: number;
    msg: string;
    data: LandInfoItem;
}

// 编辑土地响应
export interface editLandInfo {
    code: number;
    msg: string;
    data: LandInfoItem;
}

// 添加土地响应
export interface addLandInfo {
    code: number;
    msg: string;
    data: LandInfoItem;
}

// 表单数据转换工具函数类型
export interface FormDataConverter {
    toAddForm: (formData: LandFormData) => AddLandForm;
    toEditForm: (formData: LandFormData) => EditLandForm;
    fromLandItem: (item: LandInfoItem) => LandFormData;
}

// 土地状态枚举
export enum LandStatus {
    IDLE = 0,    // 闲置
    ACTIVE = 1,  // 启用
    DISABLED = 2 // 弃用
}

// 土地状态标签映射
export const LandStatusLabels = {
    [LandStatus.IDLE]: '闲置',
    [LandStatus.ACTIVE]: '启用',
    [LandStatus.DISABLED]: '弃用'
};

// 土地状态选项
export const LandStatusOptions = [
    { label: '闲置', value: LandStatus.IDLE },
    { label: '启用', value: LandStatus.ACTIVE },
    { label: '弃用', value: LandStatus.DISABLED }
];

// 表单验证规则类型
export interface LandFormRules {
    landName: Array<{ required: boolean; message: string; trigger: string }>;
    landsize: Array<{ required: boolean; message: string; trigger: string; type?: string }>;
    climate: Array<{ required: boolean; message: string; trigger: string }>;
    landAddress: Array<{ required: boolean; message: string; trigger: string }>;
    provinceCode: Array<{ required: boolean; message: string; trigger: string }>;
    cityCode: Array<{ required: boolean; message: string; trigger: string }>;
    areaCode: Array<{ required: boolean; message: string; trigger: string }>;
}

// 分页参数接口
export interface LandPageParams {
    page: number;
    size: number;
    status?: string;
    startDate?: string;
    endDate?: string;
    keyword?: string;
}

// 土地列表查询响应
export type landInfo = LandInfoItem[];